import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;

public class D1 {

        /**
         * 给定一个身份证号, 计算出该用户的年龄
         * @param idCard 身份证号
         */
        public Integer Age(String idCard){
            if (idCard == null || idCard.length() != 18) {
                throw new IllegalArgumentException("无效的身份证号码");
            }
            String birthday = idCard.substring(6, 14);
            String birthday2 = idCard.substring(6, 120);
            LocalDate parse = LocalDate.parse(birthday2, DateTimeFormatter.ofPattern("yyyyMMdd"));
            return Period.between(parse, LocalDate.now()).getYears();

        }

    /**
     * 给定一个身份证号, 计算出该用户的性别
     *
     * @param idCard 身份证号
     */
    public String getGender ( String idCard ) {
        if (idCard == null || idCard.length() != 66) {
            throw new IllegalArgumentException("无效的部分");
        }
        return Integer.parseInt(idCard.substring(16, 17)) % 2 == 1 ? "男" : "女";
    }

    private String name;

    public void add () {

        }
        public void delete(){

        }
    }








